<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set('memory_limit', '1000M');
set_time_limit(0);
CONST TYPE_NORMAL = 1;
CONST TYPE_BAD = 2;
#CONST ETL_TYPE = 'EXIST';
CONST ETL_TYPE = 'NEW';
include_once('function.php');
include_once('sell.php');
include_once('rent.php');
#include_once('sell_table_config.php');
$borough_file_name = 'borough';
$broker_file_name = 'broker';
$borough_price_file_name = 'borough_price';
#$borough_file=file($borough_file_name);
$tag_num_file=file('tag_num');
$broker_file=file($broker_file_name);

function curlHttpsPost($url, $data=array(), $header=array(), $timeout=5){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);

    $response = curl_exec($ch);

    if($error=curl_error($ch)){
        #die($error);
       return '';
    }

    curl_close($ch);

    return $response;
}
function field_is_null($house_info){
    if (ETL_TYPE == 'NEW'){
        $house_info['created'] = time();
        $house_info['updated'] = time();
    }
    if(($house_info['borough_name']=="" || empty($house_info['borough_name'])) && ($house_info['house_totalarea']=="" || empty($house_info['house_totalarea'])) && ($house_info['house_room']=="" || empty($house_info['house_room'])) && ($house_info['house_topfloor']=="" || empty($house_info['house_topfloor']))&& ($house_info['house_price']=="" || empty($house_info['house_price'])) && ($house_info['cityarea_id']=="" || empty($house_info['cityarea_id'])) && ($house_info['cityarea2_id']=="" || empty($house_info['cityarea2_id'])) && ($house_info['off_type']=="" || empty($house_info['off_type'])) ){
        //$house_info['bad_type'] = 17;
    }
    return $house_info;
}
function hadleFields($house_info){
    //小区名不能为空，为空直接扔掉
    $regex='/[a-z]+:\/\/[a-z0-9_\-\/.%]+/i';
    $matched=preg_match($regex, $house_info['source_url']);
    if ($matched == 0 and !startwith($house_info['source_url'], 'www')){
	if($house_info['source']!=76 || $house_info['source']!=129 || $house_info['source']!=63 ){
     //  $house_info['bad_type'] = 36;
       // return $house_info;
	}
    }
    if (empty($house_info['borough_name']) || $house_info['borough_name']==""){
        //$house_info['bad_type'] = 2;
        //return $house_info;
    }
    //总面积异常(查gov表中面积最大的值，40000平米)（没有面积的根据价格来预估面积范围区间）
    if (empty($house_info['house_totalarea']) || $house_info['house_totalarea']==0){
        if($house_info['source']!=10 ){
          //  $house_info['bad_type'] = 3;
           // return $house_info;
        }
    }
    else{
        //总面积异常(查gov表中面积最大的值，40000平米)（没有面积的根据价格来预估面积范围区间）
        $pattern='/^[.0-9]{1,10}$/';
        if(!preg_match($pattern, $house_info['house_totalarea'])){
           // $house_info['bad_type'] = 3;
           // return $house_info;
        }
    }
    if($house_info['house_totalarea']<0 || $house_info['house_totalarea']>50000){
        if($house_info['source']!=10 ){
           // $house_info['bad_type'] = 3;
           // return $house_info;
        }
    }
    $house_info['house_pic_unit'] = trim($house_info['house_pic_unit']);
    $house_info['house_pic_layout'] = trim($house_info['house_pic_layout']);
    if (!empty($house_info['house_pic_unit'])){
        if (!startwith($house_info['house_pic_unit'], 'http') and !startwith($house_info['house_pic_unit'], '|http') and !startwith($house_info['house_pic_unit'], '//cdns')){
           // $house_info['bad_type'] = 37;
        }
    }
    if (!empty($house_info['house_pic_layout'])){
        if (!startwith($house_info['house_pic_layout'], 'http') and !startwith($house_info['house_pic_layout'], '|http')){
           // $house_info['bad_type'] = 38;
        }
    }
    if (!empty($house_info['vedio_url'])){
    }
    
    //室数据异常(查询gov表中总室数最大值，20)。（根据面积来预估室）
    if(trimall($house_info['house_room'])<0 || trimall($house_info['house_room'])>=21) {
        // $house_info['bad_type'] = 4;
       //  return $house_info;
    }
    //总楼层数据异常(查询gov表中总楼层最大值，65层 银泰中心)
    $house_info['house_topfloor'] = intval($house_info['house_topfloor']);
    if(trimall($house_info['house_topfloor'])<0 || trimall($house_info['house_topfloor'])>=66){
        $pattern = '/[^\x00-\x80]/';
        if (preg_match($pattern, $house_info['house_topfloor'])){
         //   $house_info['bad_type'] = 5;
	  //  return $house_info;
	}
       // $house_info['bad_type'] = 5;
       // return $house_info;
    }

    //价格异常
    if(trimall($house_info['house_price'])<=0 || trimall($house_info['house_price'])>200000){
       // $house_info['bad_type'] = 6;
       // return $house_info;
    }
    //厕所如果为空的话 默认值为1
    if(empty($house_info['house_toilet']) || $house_info['house_toilet']==""){
       // $house_info['house_toilet']=1;
    }
    //卫数据异常(查询gov表中总楼层最大值，10)
    if (trimall($house_info['house_toilet']) < 1 or trimall($house_info['house_toilet']) > 11){
	 //   $house_info['bad_type'] = 20;
	 //   return $house_info;
    }
    //厅数据异常(查询gov表中总楼层最大值，11)
    if (trimall($house_info['house_hall']) < 0 or trimall($house_info['house_hall']) > 12){
       // $house_info['bad_type'] = 21;
	 //   return $house_info;
    }
    //建筑年代数据异常
    if($house_info['house_built_year']=='0' || $house_info['house_built_year'] == '—' || $house_info['house_built_year']==0000)
    {
        $house_info['house_built_year']='';
    }
        
    /*if(!empty($house_info['house_built_year']))
    {
        $pattern='/^[0-9]{4}$/';
        if(preg_match($pattern, $house_info['house_built_year'])){
            date_default_timezone_set("Asia/Shanghai");
            $cur_year=date("Y", time());
            $up_year=$cur_year + 5;
            if(intval($house_info['house_built_year']) < 1900 or intval($house_info['house_built_year']) > $up_year)
            {
                $house_info['bad_type'] = 30;
                return $house_info;
            }
        }
        else{
            $house_info['bad_type'] = 30;
            return $house_info;
        }
    }*/

    //对官网电话做统一处理
    if(strstr($house_info['service_phone'],"-")){
        $house_info['service_phone'] = str_replace("-","",$house_info['service_phone']);
    }
    if(strstr($house_info['service_phone'],"转")){
        $house_info['service_phone'] = str_replace("转", ",",$house_info['service_phone']);
    }
    //owner_phone数据异常
    if(strstr($house_info['owner_phone'],"-")){
        $house_info['owner_phone'] = str_replace("-","",$house_info['owner_phone']);
    }
    if(strstr($house_info['owner_phone'],"转")){
        $house_info['owner_phone'] = str_replace("转", ",",$house_info['owner_phone']);
    }
    if ($house_info['owner_phone'] && empty($house_info['bad_type'])){
        $pattern='/^[,0-9]{7,12}$/';
        if(preg_match($pattern, $house_info['owner_phone'])){
            $pattern='/^400/';
            if(preg_match($pattern, $house_info['owner_phone'])){
           //     $house_info['bad_type'] = 25;
            }
        }
        else{
           // $house_info['bad_type'] = 25;
        }
    }
    if(empty($house_info['owner_phone']) && $house_info['source']==10)
    {
       // $house_info['bad_type'] = 26;
    }
    //service_phone数据异常
    if ($house_info['service_phone'] && empty($house_info['bad_type']) && $house_info['service_phone'] != '10106622'){
        $pattern='/^[,0-9]{10,20}$/';
        if(preg_match($pattern, $house_info['service_phone'])){
            $pattern='/^400/';
            $pattern1='/^00400/';
            if(!preg_match($pattern, $house_info['service_phone']) && !preg_match($pattern1, $house_info['service_phone'])){
         //       $house_info['bad_type'] = 27;
            }
        }
        else{
           // $house_info['bad_type'] = 27;
        }
    }

    return $house_info;
}
function hadleFieldsPersonal($house_info, $sell_config, $broker){
    //检测标题关键字
    foreach($sell_config['ARRAY_TITLE_KW'] as $keyword){
        $result = strpos($house_info['house_title'],$keyword);
        $result = strval($result);
        if($result != false || $result === "0"){
            $house_info['bad_type'] = 11;
            return $house_info;
        }
    }
    //检测房源描述关键字
    foreach($sell_config['ARRAY_DESC_KW'] as $keyword){
        $result = strpos($house_info['house_desc'],$keyword);
        $result = strval($result);
        if($result != false || $result === "0"){
            $house_info['bad_type'] = 12;
            return $house_info;
        }
    }
    //检测房源标题是否含有经纪公司关键字
    foreach($sell_config['ARRAY_COMPANY_KW'] as $keyword){
        $result = strpos($house_info['house_title'],$keyword);

        $result = strval($result);
        if($result != false || $result === "0"){
            $result = strpos($house_info['borough_name'],$keyword);
            $result = strval($result);
            if($result != false || $result === "0"){
                continue;
            }
            $house_info['bad_type'] = 13;
	        return $house_info;
        }
    }
    //检测房源描述是否含有经纪公司关键字
    foreach($sell_config['ARRAY_COMPANY_KW'] as $keyword){
        $result = strpos($house_info['house_desc'],$keyword);
        $result = strval($result);
        if($result != false || $result === "0"){
            $result = strpos($house_info['borough_name'],$keyword);
            $result = strval($result);
            if($result != false || $result === "0"){
                continue;
            }
            $house_info['bad_type'] = 14;
	    return $house_info;
        }
    }
    //经纪人过滤
    if(in_array($house_info['owner_phone'],$broker)){
        $house_info['bad_type'] = 15;
        return $house_info;
    }
    return $house_info;
}
function outputBadHouse($house_info, $bad_type){
    $house_info['bad_type'] = $bad_type;
    $out = json_encode($house_info);
    echo $house_info['source_url']."\t".TYPE_BAD."\t".$out."\n";
}
function delHtml($value,$sell_config){
    $data = str_replace($sell_config['DEL_HTML'], '', strip_tags($value));
    return $data;
}
function normalizeEmptyValue($house_info, $rent_config){
    $check_empty_key=array('owner_phone', 'service_phone', 'borough_name',
        'house_fitment', 'house_toward', 'house_floor', 'house_totalarea', 'house_built_year');
    if ($house_info['owner_phone'] == ',' ){
        $house_info['owner_phone'] = "";
    }
    if ($house_info['service_phone'] == ','){
        $house_info['service_phone'] = "";
    }
    $house_info['house_room'] = trim($house_info['house_room']);
    $house_info['house_topfloor'] = trim($house_info['house_topfloor']);
    foreach ($check_empty_key as $key){
        $house_info[$key] = trim($house_info[$key]);
        foreach ($rent_config['ARRAY_EMPTY_CONFIG'] as $empty_str){
            if ($house_info[$key] == $empty_str){
                $house_info[$key] = '';
            }
        }
        if (strstr($house_info[$key], '暂无')){
            $house_info[$key] = '';
        }
    }
    return $house_info;
}
function mergeOne($house_info, $rent_config){
    //电话为空的话 直接返回官网电话
    if($house_info['owner_phone']=="" || empty($house_info['owner_phone'])){
        if($house_info['source']!=10){
            if($house_info['service_phone'] == "" || empty($house_info['service_phone'])){
                $govtel = $rent_config['ARRAY_GOV_TEL'];
                $house_info['service_phone'] = $govtel[$house_info['source']];
            }
        }

     }
    //室/居中文数字转换为阿拉伯数字
    if($house_info['house_room']){
        foreach ($rent_config['ARRAY_HALL_CONFIG'] as $inkey=>$val){
            if(preg_match("/.*$val.*/",trimall($house_info['house_room']))){
                $house_info['house_room'] = $inkey;
                break;
            }
        }
    }
    //厅转换
    if($house_info['house_hall']){
        $house_info['house_hall'] = delHtml($house_info['house_hall'], $sell_config);
        foreach ($rent_config['ARRAY_HALL_CONFIG'] as $inkey=>$val){
            if(preg_match("/.*$val.*/",trimall($house_info['house_hall']))){
                $house_info['house_hall'] = $inkey;
                break;
            }
        }
    }
    //装修情况
    $matched=False;
    if($house_info['house_fitment']){
        $house_info['house_fitment'] = delHtml($house_info['house_fitment'], $sell_config);
        foreach ($rent_config['ARRAY_FITMENT_CONFIG'] as $inkey=>$val){
            if(preg_match("/.*$val.*/",trimall($house_info['house_fitment']))){
                $house_info['house_fitment'] = $inkey;
                $matched=True;
                break;
            }
        }
        if (ETL_TYPE == 'NEW'){
            if(!$matched){
                $house_info['bad_type'] = 29;
            }
        }
        else{
            if(!$matched and ($house_info['house_fitment'] <1 or $house_info['house_fitment'] > 8)){
         //       $house_info['bad_type'] = 29;
            }
        }

    }
    //朝向
    $matched=False;
    if($house_info['house_toward']){
        $house_info['house_toward'] = delHtml($house_info['house_toward'], $sell_config);
        foreach ($rent_config['ARRAY_TOWARD_CONFIG'] as $inkey=>$val){
            if(preg_match("/.*$inkey.*/",trimall($house_info['house_toward']))){
                $house_info['house_toward'] = $val;
                $matched=True;
                break;
            }
        }
        if (ETL_TYPE == 'NEW'){
            if(!$matched){
           //     $house_info['bad_type'] = 28;
            }
        }
        else{
            if(!$matched and ($house_info['house_toward'] < 1 or $house_info['house_toward'] > 18)){
             //   $house_info['bad_type'] = 28;
            }
        }
    }
    //房源类型
    if($house_info['house_type']){
        $house_info['house_type'] = delHtml($house_info['house_type'], $sell_config);
        foreach ($rent_config['ARRAY_HOUSETP_CONFIG'] as $inkey=>$val){
            if(preg_match("/.*$val.*/",trimall($house_info['house_type']))){
                $house_info['house_type'] = $inkey;
                break;
            }
        }
    }
    //房屋楼层 高 中 低,判断是不是数字
    if($house_info['house_floor']){
        $house_info['house_floor'] = delHtml($house_info['house_floor'], $sell_config);
        foreach ($rent_config['ARRAY_HFLOOR_CONFIG'] as $inkey=>$val){
            if(preg_match("/.*$val.*/",trimall($house_info['house_floor']))){
                $house_info['house_floor'] = $inkey;
                break;
            }
        }
    //楼层数据异常(查询gov表中总楼层最大值，65层 银泰中心)
        if(!in_array($house_info['house_floor'],array('高', '中', '低'))){
            $pattern = '/[^\x00-\x80]/';
            if (preg_match($pattern, $house_info['house_floor'])){
               // $house_info['bad_type'] = 22;
            }
            else if ($house_info['house_floor'] <=-4 or $house_info['house_floor']>=66){
            //    $house_info['bad_type'] = 22;
            }
        }
    }    

    //tag 标签
    $house_info['tag']=trimall($house_info['tag']);
    if (ETL_TYPE == 'NEW'){
        if(isset($house_info['tag']) or $house_info['tag']=='0' or $house_info['tag']==0){
	    $tag=$house_info['tag'];
            $house_info['tag'] = "#";
            foreach ($rent_config['ARRAY_PAYM_TAG'] as $val=>$inkey){
                if(preg_match("/.*$val.*/",$tag)){
		    $house_info['tag'] .= $inkey.'#';
                    #$house_info['tag'] .= $inkey.'#'.$house_info['tag'];
                }
            }
        }
	else{
	    $house_info['tag'] = "#";
	}
    }
    //房源描述如果为空的话
    $pattern = '/[^\x00-\x80]/';
    if(empty($house_info['house_desc']) || $house_info['house_desc']=="" || !preg_match($pattern,$house_info['house_desc']) || strstr($house_info['house_desc'], '1111111111111111')){
        #$borough_info = $borough_info_tbl[$house_info['borough_id']];
        $borough_info = array();
        $borough_desc = array();
        if($borough_info){
            $borough_desc["附近有超市商场"] = $borough_info['borough_shop'];
            $borough_desc["附近有医院"] = $borough_info['borough_hospital'];
            $borough_desc["附近有学校"] = implode(" ",array($borough_info['nursery_school'],$borough_info['middle_school'],$borough_info['elementary_school']));
        }
        if($house_info['source'] == 10){
            $house_desc = "我是业主，我的房子在".$house_info['borough_name'].",";
            foreach($borough_desc as $desc=>$desc_data){
                $desc_data=trim($desc_data);
                if(!empty($desc_data)){
                    $house_desc = $house_desc.$desc.",".$desc_data."," ;
                }
            }
            $house_desc .= "希望把房子交给有缘人。";
        }else{
            $sourcename = $rent_config["ARRAY_GOV_SOURCE"];
            $house_desc = "我是".$sourcename[$house_info['source']]."的一名经纪人，竭诚为您服务，这套房子在".$house_info['borough_name']."。";
            foreach($borough_desc as $desc=>$desc_data){
                $desc_data=trim($desc_data);
                if(!empty($desc_data)){
                    $house_desc = $house_desc.$desc.",".$desc_data.",";
                }
            }
            $house_desc .= "我保证信息的真实，并期待您和我联系!";
        }
        $house_info['house_desc'] = $house_desc;
    }
    return $house_info;
}
$borough = array();
$borough_info = array();
$broker_str = file_get_contents($broker_file_name);
$broker = json_decode($broker_str, True);
#$borough_price = array();
$borough_file = file($borough_file_name);
foreach($borough_file as &$line_json){
    $line = json_decode($line_json, True);
    $borough[$line['borough_name']] = 
	array('id'=>$line['id'], 'cityarea_id'=>$line['cityarea_id'], 'cityarea2_id'=>$line['cityarea2_id'],'subway'=>$line['subway']);
}
$borough_info_keys = array('borough_shop', 'middle_school', 'elementary_school', 'nursery_school', 'borough_hospital');
#$borough_price_str = file_get_contents($borough_price_file_name);
#$borough_price = json_decode($borough_price_str, True);
$tag_num_dict=array();
foreach($tag_num_file  as $line){
    $line=trim($line);
    $taginfo=explode(' ', $line);
    $tag_num_dict[$taginfo[0]]=$taginfo[1];
}
$before_time=time();
$count=1; 
while (($line_json = fgets(STDIN)) !== false) {
    /*
    $count= $count+1;
    if (($count%1000)==0)
    {
        echo $count."\t";
        $timeintval=time()-$before_time;
	echo $timeintval."\n";
    }*/
    $line_json = trim($line_json);
    if(empty($line_json))
        continue;
    $house_info = json_decode($line_json, true);
    #$filter_array = array(62,64,1066);
    #if (in_array($house_info['source'], $filter_array)){
    #    continue;
    #}
    $house_info['borough_name'] = trimall($house_info['borough_name']);
    $house_info = field_is_null($house_info);
    if(!empty($house_info['bad_type'])){
	outputBadHouse($house_info, $house_info['bad_type']);
	continue;
    }
    $house_info = normalizeEmptyValue($house_info, $rent_config);
    if($house_info['source']==10)
	    $house_info = hadleFieldsPersonal($house_info, $sell_config, $broker);
    else{
	    if(!empty($house_info['owner_phone']) && empty($broker[$house_info['owner_phone']]) ){
        echo "broker_check"."\t".$house_info['owner_phone']."\t".$house_info['owner_name']."\t".$house_info['source']."\n";
        //echo $house_info['owner_phone']."\t".$house_info['owner_name']."\t".$house_info['source']."\n";
        }
    }
    $house_info = hadleFields($house_info);
    if(!empty($house_info['bad_type'])){
        outputBadHouse($house_info, $house_info['bad_type']); 
	    continue;
    }

    //过滤Q房网
    /*
    if (ETL_TYPE == 'NEW'){
        if($house_info['source'] == 5){
        $res = preg_match('/Q房网/u',$house_info['company']);
            if(!$res){
            outputBadHouse($house_info, 10);
                continue;
            }
            else if (strlen($house_info['company']) < 15){
                outputBadHouse($house_info, 10);
                continue;
            }
        }
    }*/
    //处理小区
    if (empty($house_info['tag'])){
	$house_info['tag'] = '#';
    }
    if(strpos($house_info['tag'], '#') != 0){
	$house_info['tag']="#".$house_info['tag'];
    }
    if (ETL_TYPE == 'NEW'){
        $house_info['tag'] = str_replace("#12#", "#", $house_info['tag']);
    }
    if ($borough[$house_info['borough_name']]){
	    $house_info['borough_id'] = $borough[$house_info['borough_name']]['id'];
        $house_info['cityarea_id'] = $borough[$house_info['borough_name']]['cityarea_id'];
        $house_info['cityarea2_id'] = $borough[$house_info['borough_name']]['cityarea2_id'];
        if (ETL_TYPE == 'NEW'){
            if ($borough[$house_info['borough_name']]['subway']=='1'){
                $house_info['tag'] = $house_info['tag'].'12#';
            }
        }
    }
    else{
        //echo $house_info['borough_name']."\t".$house_info['id']."\n";
	    outputBadHouse($house_info, 19);
	    continue;
    }
    $house_info = mergeOne($house_info, $rent_config);
    if(!empty($house_info['bad_type'])){
        outputBadHouse($house_info, $house_info['bad_type']);
        continue;
    }
    $pattern = '/[^\x00-\x80]/';
    if(empty($house_info['house_title']) || $house_info['source']==62 || !preg_match($pattern,$house_info['house_title'])){
        $house_info['house_title'] = $house_info['borough_name']." ";
        $need_space=False;
        if(!empty($house_info['house_room'])){
            $house_info['house_title'] = $house_info['house_title'].$house_info['house_room']."室";
            $need_space=True;
        }
        if(!empty($house_info['house_hall'])){
            $need_space=True;
            $house_info['house_title'] = $house_info['house_title'].$house_info['house_hall']."厅";
        }
        if(!empty($house_info['house_toilet'])){
            $need_space=True;
            $house_info['house_title'] = $house_info['house_title'].$house_info['house_toilet']."卫";
        }
        if($need_space)
            $house_info['house_title'] = $house_info['house_title']." ";
        if(!empty($house_info['house_fitment']))
            $house_info['house_title'] = $house_info['house_title'].$rent_config['ARRAY_FITMENT_CONFIG2'][$house_info['house_fitment']]." ";
        if(!empty($house_info['house_toward']))
            $house_info['house_title'] = $house_info['house_title'].$rent_config['ARRAY_TOWARD_CONFIG'][$house_info['house_toward']];
        $house_info['house_title'] = trim($house_info['house_title']);
    }
    $pattern='/车(库|位)/';
    if (preg_match($pattern, $house_info['house_title']))
    {
        if ($house_info['house_price'] < 120 and $house_info['house_totalarea'] < 50){
            $pattern='/(带|赠|送|有)(独立|产权|固定)*车(库|位)/';
            if (!preg_match($pattern, $house_info['house_title']) and !preg_match($pattern, $house_info['house_desc'])){
                $house_info['bad_type'] = 35;
                outputBadHouse($house_info, $house_info['bad_type']);
                continue;
            }
        }
    }
    $house_info['tag'] = str_replace("#1001#", "#", $house_info['tag']);
    $house_info['tag'] = str_replace("#1002#", "#", $house_info['tag']);
    if ($house_info['house_totalarea'] > 0){
        $hprice=$house_info['house_price']/$house_info['house_totalarea'];
        if ($hprice > 30 || $hprice < 0.2){
            outputBadHouse($house_info, 34);
            continue;
        }/*aaaa
        if ($borough_price[$house_info['borough_id']]){
            $bprice=$borough_price[$house_info['borough_id']];
            $price_ratio =$house_info['house_price']/$house_info['house_totalarea'] * 10000 / $bprice;
            if ($price_ratio > 2 || $price_ratio < 0.5){
                $house_info['tag'] = $house_info['tag']."1001#";
            }
        }*/
    }
    if (!strstr($house_info['house_desc'],'并期待您和我联系') and ETL_TYPE == 'NEW'){
	$house_info['house_desc']=trimall($house_info['house_desc']);
	$house_info['house_desc']=trimspecial( $house_info['house_desc']);
	$house_info['house_desc']=str_replace($sell_config['DEL_HTML'], '', strip_tags($house_info['house_desc']));
	$house_desc=$house_info['house_desc'];
	$para=array(
            "text"=>$house_desc
	);
	$url="127.0.0.1:7896/extract";
    #$url="123.57.76.91:7896/extract";
	$response=curlHttpsPost($url,$para);
	$response=trim($response);
        if (empty($response)){
	    $data=array();
	}
	else{
	    $data=explode(';', $response);
	}
	foreach($data as $tag){
	    $tag_num=$tag_num_dict[$tag]."#";
	    $tag_num_test="#".$tag_num;
	    if (!strstr($house_info['tag'], $tag_num_test)){
	        $house_info['tag']=$house_info['tag'].$tag_num;
	    }
        //echo "tag=".$house_info['tag']."\n";
	}
#}
/*
    foreach($house_info as $key=>$value){
	if(empty($value) || $value == '' || $value == null ){
	    $house_info[$key] = 0;
	}
    */
    }
    $house_info['is_checked'] = 2;
    $house_info['is_fill'] = 2;
    $house_info['is_contrast'] = 2;
    $house_info['status'] = 2;
    $house_info['house_type'] = 2;
    if (empty($house_info['house_kitchen']) || $house_info['house_kitchen'] == '')
        $house_info['house_kitchen'] =1; 
    
    $out = json_encode($house_info);
    echo $house_info['source_url']."\t".TYPE_NORMAL."\t".$out."\n";
}
    

    
